import scrapy


class XcSpider(scrapy.Spider):
    name = 'xc'
    allowed_domains = ['ctrip.com']
    start_urls = ['https://www.ctrip.com/']

    def start_requests(self):
        url = "https://hotels.ctrip.com/Domestic/Tool/AjaxGetCitySuggestion.aspx"
        yield scrapy.Request(
            url,
            callback=self.parse
        )

    def parse(self, response):
        pass

    # list page1  ('"firstPageList":(.*?),"sortInfo":', )[0] + "}"
    #      page2  https://m.ctrip.com/restapi/soa2/16709/json/HotelSearch?testab=1659a052be10ce3e3cdc88c0f191b7f94269c7317dce02b9dafe37ad1426d9bb
    #      page3  https://m.ctrip.com/restapi/soa2/16709/json/HotelSearch?testab=844158c35683b4bc79c7a42ece0dac667c3f9507b881451c812caa4fddf584d7
    #          4  https://m.ctrip.com/restapi/soa2/16709/json/HotelSearch?testab=fd52ee6411a7fdc891b17d71b7b4876e052c23a0ffa50c68695a7310a44cafdf

    #  post 2 {"meta":{"fgt":"","hotelId":"","priceToleranceData":"","priceToleranceDataValidationCode":"","mpRoom":[],"hotelUniqueKey":"","shoppingid":"","minPrice":"","minCurr":""},"seqid":"","deduplication":[66684700,2622151,61616470,426206,63448967,654875,1597092,67690986,52682020,54499290,52757901,48702888],"filterCondition":{"star":[],"rate":"","rateCount":[],"priceRange":{"lowPrice":0,"highPrice":-1},"priceType":"","breakfast":[],"payType":[],"bedType":[],"bookPolicy":[],"bookable":[],"discount":[],"zone":[],"landmark":[],"metro":[],"airportTrainstation":[],"location":[],"cityId":[],"amenty":[],"promotion":[],"category":[],"feature":[],"brand":[],"popularFilters":[],"hotArea":[],"ctripService":[]},"searchCondition":{"sortType":"1","adult":1,"child":0,"age":"","pageNo":2,"optionType":"City","optionId":"30","lat":0,"destination":"","keyword":"","cityName":"深圳","lng":0,"cityId":30,"checkIn":"2020-11-02","checkOut":"2020-11-03","roomNum":1,"mapType":"gd","travelPurpose":0,"countryId":1,"url":"https://hotels.ctrip.com/hotels/listPage?cityename=shenzhen&city=30&optionId=30&optionType=City&checkin=2020/11/2&checkout=2020/11/03&crn=1&adult=1&children=0#abtest=200820_HTL_cdhwp:B;","pageSize":10,"timeOffset":28800,"radius":0,"directSearch":0,"signInHotelId":0,"signInType":0},"queryTag":"NORMAL","genk":true,"genKeyParam":{"a":0,"b":"2020-11-02","c":"2020-11-03","d":"zh-cn","e":2},"webpSupport":true,"platform":"online","pageID":"102002","head":{"Version":"","userRegion":"CN","Locale":"zh-CN","LocaleController":"zh-CN","TimeZone":"8","Currency":"CNY","PageId":"102002","webpSupport":true,"userIP":"","P":"75571333477","ticket":"","clientID":"1603222407883.1y9e2k","group":"ctrip","Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":53},"Union":{"AllianceID":"","SID":"","Ouid":""},"HotelExtension":{"group":"CTRIP","hasAidInUrl":false,"Qid":"960324558169","WebpSupport":true,"hotelUuidKey":"DT4JS1YM5ez9E9trAYpNY1oEzYUkeadEXsjNQWhYZFvQHWcPr8UxAYAFrFOwdMv0kIPYMfea5wsNvBtJ0Yl4vQSYAGRZAjSavDXWOXYQHjFsy5Yh0vBqjUgYXDws1jLkeQ6ih0YgY0YPBvcbeQTY0niMDYTYNYLcIchWSYonYHmi1li4lin8jbYd0wl0EFoYgHwdfEqMJ0LYPDw8YA3RQ6wo3WblEO6iA1RT4Jn6wflJHGvFXWDzyB4E5YTnRX1wAaImmxTaj0GjNGe6DjnaittxMPiznYk8E34yNDWBbJoY1ORDOw3kW08i1QYsSYPnYNXEHcWMbyOAjAXjasi5YMqjFbw5mvltj1YDPROXJNbit3wTleSLjFdwOlEaYz8RFlJc3iLswdoet8j13YDGEtYO1RNBwM5WptEmXic6R9ZipGwD5JtfyO7vPkWh5"}}}
    #       3 {"meta":{"fgt":"","hotelId":"","priceToleranceData":"","priceToleranceDataValidationCode":"","mpRoom":[],"hotelUniqueKey":"","shoppingid":"","minPrice":"","minCurr":""},"seqid":"","deduplication":[66684700,2622151,61616470,426206,63448967,654875,1597092,67690986,52682020,54499290,52757901,48702888,67517919,15251482,6871167,67685680,49706754,52112081,60317444,61002063,535627,512791,5860925,456133],"filterCondition":{"star":[],"rate":"","rateCount":[],"priceRange":{"lowPrice":0,"highPrice":-1},"priceType":"","breakfast":[],"payType":[],"bedType":[],"bookPolicy":[],"bookable":[],"discount":[],"zone":[],"landmark":[],"metro":[],"airportTrainstation":[],"location":[],"cityId":[],"amenty":[],"promotion":[],"category":[],"feature":[],"brand":[],"popularFilters":[],"hotArea":[],"ctripService":[]},"searchCondition":{"sortType":"1","adult":1,"child":0,"age":"","pageNo":3,"optionType":"City","optionId":"30","lat":0,"destination":"","keyword":"","cityName":"深圳","lng":0,"cityId":30,"checkIn":"2020-11-02","checkOut":"2020-11-03","roomNum":1,"mapType":"gd","travelPurpose":0,"countryId":1,"url":"https://hotels.ctrip.com/hotels/listPage?cityename=shenzhen&city=30&optionId=30&optionType=City&checkin=2020/11/2&checkout=2020/11/03&crn=1&adult=1&children=0#abtest=200820_HTL_cdhwp:B;","pageSize":10,"timeOffset":28800,"radius":0,"directSearch":0,"signInHotelId":0,"signInType":0},"queryTag":"NORMAL","genk":true,"genKeyParam":{"a":0,"b":"2020-11-02","c":"2020-11-03","d":"zh-cn","e":2},"webpSupport":true,"platform":"online","pageID":"102002","head":{"Version":"","userRegion":"CN","Locale":"zh-CN","LocaleController":"zh-CN","TimeZone":"8","Currency":"CNY","PageId":"102002","webpSupport":true,"userIP":"","P":"75571333477","ticket":"","clientID":"1603222407883.1y9e2k","group":"ctrip","Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":53},"Union":{"AllianceID":"","SID":"","Ouid":""},"HotelExtension":{"group":"CTRIP","hasAidInUrl":false,"Qid":"960324558169","WebpSupport":true,"hotelUuidKey":"N1mwb6YgTeUNE4HEsYMAYq4ELYdte05EQLjd9WHYFsrb3IsNvUkj8Yo6jLMWgkvb1jfYUtEADwFmizljDYX7eGmw9ZvMcjhbvs1eoZYBgjO4yXY5XyN7vGDYDlwMpjQ3edSiFTYkYlYSMv9QeQaYtcio9YfYtYLTIgnWzY3Aef1iAZiNpik9jsY37whXEoAYpawlkE08Jc1YalwNYdMRpZwsAWoZEfTiDcRtFJfdvahwTlWd5JtlwhZwUYtTR3lwaoImmx45jszjc5eHUjLliPPxlbidlY1gEqzy86WUFJgYDtRZQw1bWhXimlYlXYNtYg3E8tWT4yA4jt3jFkiNYnZjN0wMDvQajcYfORzsJF7i4Qwk5egBjkpw3QEnY0FR64JgQi5UwhNeSnjOdYBkEMYdNRmgwUTWNZEfSioHRODicmw4XJBmyS3vcGWBs"}}}
    #       4 {"meta":{"fgt":"","hotelId":"","priceToleranceData":"","priceToleranceDataValidationCode":"","mpRoom":[],"hotelUniqueKey":"","shoppingid":"","minPrice":"","minCurr":""},"seqid":"","deduplication":[66684700,2622151,61616470,426206,63448967,654875,1597092,67690986,52682020,54499290,52757901,48702888,67517919,15251482,6871167,67685680,49706754,52112081,60317444,61002063,535627,512791,5860925,456133,55237459,347435,61470013,55212528,53784914,29520377,371241,1195066,8003245,45938744],"filterCondition":{"star":[],"rate":"","rateCount":[],"priceRange":{"lowPrice":0,"highPrice":-1},"priceType":"","breakfast":[],"payType":[],"bedType":[],"bookPolicy":[],"bookable":[],"discount":[],"zone":[],"landmark":[],"metro":[],"airportTrainstation":[],"location":[],"cityId":[],"amenty":[],"promotion":[],"category":[],"feature":[],"brand":[],"popularFilters":[],"hotArea":[],"ctripService":[]},"searchCondition":{"sortType":"1","adult":1,"child":0,"age":"","pageNo":4,"optionType":"City","optionId":"30","lat":0,"destination":"","keyword":"","cityName":"深圳","lng":0,"cityId":30,"checkIn":"2020-11-02","checkOut":"2020-11-03","roomNum":1,"mapType":"gd","travelPurpose":0,"countryId":1,"url":"https://hotels.ctrip.com/hotels/listPage?cityename=shenzhen&city=30&optionId=30&optionType=City&checkin=2020/11/2&checkout=2020/11/03&crn=1&adult=1&children=0#abtest=200820_HTL_cdhwp:B;","pageSize":10,"timeOffset":28800,"radius":0,"directSearch":0,"signInHotelId":0,"signInType":0},"queryTag":"NORMAL","genk":true,"genKeyParam":{"a":0,"b":"2020-11-02","c":"2020-11-03","d":"zh-cn","e":2},"webpSupport":true,"platform":"online","pageID":"102002","head":{"Version":"","userRegion":"CN","Locale":"zh-CN","LocaleController":"zh-CN","TimeZone":"8","Currency":"CNY","PageId":"102002","webpSupport":true,"userIP":"","P":"75571333477","ticket":"","clientID":"1603222407883.1y9e2k","group":"ctrip","Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":53},"Union":{"AllianceID":"","SID":"","Ouid":""},"HotelExtension":{"group":"CTRIP","hasAidInUrl":false,"Qid":"960324558169","WebpSupport":true,"hotelUuidKey":"N1mwb6YgTeUNE4HEsYMAYq4ELYdte05EQLjd9WHYFsrb3IsNvUkj8Yo6jLMWgkvb1jfYUtEADwFmizljDYX7eGmw9ZvMcjhbvs1eoZYBgjO4yXY5XyN7vGDYDlwMpjQ3edSiFTYkYlYSMv9QeQaYtcio9YfYtYLTIgnWzY3Aef1iAZiNpik9jsY37whXEoAYpawlkE08Jc1YalwNYdMRpZwsAWoZEfTiDcRtFJfdvahwTsYd6WtlwhmvUYtTR3lwaoImmx45jszjc5eHUjLliPPxlbidlY1gEqzy86WUFJgYDtRZQw1bWhXimlYlXYNtYg3E8tWT4yA4jt3jFkiNYnZjN0wMDvQajcYfORzsJF7i4Qwk5egBjkpw3QEnY0FR64JgQi5UwhNeSnjOdYBkEMYdNRmgwUTWNZEfSioHRODicmw4XJBmyS3vcGWBs"}}}

    # detail
    # 详情 介绍政策  https://m.ctrip.com/restapi/soa2/16709/json/hotelStaticInfo
    #   post  {"masterHotelId":66684700,"isBusiness":false,"feature":[],"cityCode":30,"head":{"Locale":"zh-CN","Currency":"CNY","Device":"PC","UserIP":"120.229.32.224","Group":"","ReferenceID":"","UserRegion":"CN","AID":"4897","SID":"130026","Ticket":"","UID":"","IsQuickBooking":"","ClientID":"1603222407883.1y9e2k","OUID":"","TimeZone":"8","P":"75571333477","PageID":"102003","Version":"","HotelExtension":{"WebpSupport":true,"group":"CTRIP","Qid":"960324558169","hasAidInUrl":false},"Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":68}},"ServerData":""}

    # 房间   https://m.ctrip.com/restapi/soa2/16709/json/rateplan?testab=9ed62cf51fad92eb8884a5bc55c61393bbabb1563bd617ff0e1bc6ad2ba45d95
    #   post  {"checkIn":"2020-11-02","checkOut":"2020-11-03","priceType":"","adult":1,"popularFacilityType":"","mpRoom":"","fgt":"","hotelUniqueKey":"","child":0,"roomNum":1,"masterHotelId":66684700,"age":"","cityId":"30","roomkey":"","minCurr":"","minPrice":"","hotel":"66684700","ctripTrace":{"listRoomId":911641238,"listShadowId":0,"listPrice_cx":"316","exchange":"1.0","currency":"RMB","maskDifAvgCnyPrice":"0"},"filterCondition":{},"genk":true,"genKeyParam":{"a":66684700,"b":"2020-11-02","c":"2020-11-03","d":"zh-cn","e":2},"head":{"Locale":"zh-CN","Currency":"CNY","Device":"PC","UserIP":"120.229.32.224","Group":"","ReferenceID":"","UserRegion":"CN","AID":"4897","SID":"130026","Ticket":"","UID":"","IsQuickBooking":"","ClientID":"1603222407883.1y9e2k","OUID":"","TimeZone":"8","P":"75571333477","PageID":"102003","Version":"","HotelExtension":{"WebpSupport":true,"group":"CTRIP","Qid":"960324558169","hasAidInUrl":false,"hotelUuidKey":"nTBJpFKfmeL3EBdJbYU3YSLE9YDQeL5EHUj50WOY8XIh8wz4vBmWpYsHjQMxkOv5bjlYd6j8nWtHv1LyHYaNvBZKF0yg1jaXvNFe5NEBtjzty0YAzvclvGpYXpwBGEt1ePoiFpYqYUY07vAleLgYf5iDhY1YLYmMIbMWaY6XYU3idnikXia4jNYzFw3FEMDYHLwoHE1nJQaYtPwdYozRTDwAXWFfEl0inARBbwMhEDcwG4wqkE93j7ojXYtbRsXwt1IGGxF3j0bj3geBcjtPi44xoFiTmYbgENfytGWZTJLYFHRDQwz1WmFiH6YsqYdFYGNE1GW7py3tjc5jk9iDYLmjT4wdAvs1jgYhkRUhJnSi5pwdpehljbOwk5E1YNDRtDJAbiL5wS5enkjDGYcPEqYG6RZ7whnW9kElkiq4Rkqw3FE1tw4Bwq1Ec6Wqn","hotelUuid":"16LXVtZGQXBPC7lS"},"Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":68}},"ServerData":""}

    # 评价 评论  https://m.ctrip.com/restapi/soa2/16709/json/GetReviewList
    #   post  {"PageNo":1,"PageSize":10,"MasterHotelId":66684700,"NeedFilter":true,"UnUsefulPageNo":1,"UnUsefulPageSize":5,"isHasFold":false,"head":{"Locale":"zh-CN","Currency":"CNY","Device":"PC","UserIP":"120.229.32.224","Group":"","ReferenceID":"","UserRegion":"CN","AID":"4897","SID":"130026","Ticket":"","UID":"","IsQuickBooking":"","ClientID":"1603222407883.1y9e2k","OUID":"","TimeZone":"8","P":"75571333477","PageID":"102003","Version":"","HotelExtension":{"WebpSupport":true,"group":"CTRIP","Qid":"960324558169","hasAidInUrl":false},"Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":68}},"ServerData":""}

    # 附近美食景点地铁等  https://m.ctrip.com/restapi/soa2/16709/json/hotelPlaceInfo
    #   post  {"masterHotelId":66684700,"cityId":30,"mapType":"bd","isNewMap":"1","head":{"Locale":"zh-CN","Currency":"CNY","Device":"PC","UserIP":"120.229.32.224","Group":"","ReferenceID":"","UserRegion":"CN","AID":"4897","SID":"130026","Ticket":"","UID":"","IsQuickBooking":"","ClientID":"1603222407883.1y9e2k","OUID":"","TimeZone":"8","P":"75571333477","PageID":"102003","Version":"","HotelExtension":{"WebpSupport":true,"group":"CTRIP","Qid":"960324558169","hasAidInUrl":false},"Frontend":{"vid":"1603222407883.1y9e2k","sessionID":10,"pvid":68}},"ServerData":""}


